package com.bdqn.spark.chapter05.kv

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark25_RDD_Operator_Transform {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf()
      .setMaster("local[*]")
      .setAppName("operator-leftOuterJoin")
    val sc = new SparkContext(sparkConf)

    // 算子 - (Key - Value类型)
    val rdd1: RDD[(String, Int)] = sc.makeRDD(List(
      ("a", 1), ("b", 2) //, ("c", 3)
    ))

    val rdd2: RDD[(String, Int)] = sc.makeRDD(List(
      ("a", 4), ("b", 5), ("c", 6),("a", 3)
    ))

    // 合流
    rdd2.leftOuterJoin(rdd1).collect().foreach(println)


    sc.stop()
  }
}
